using System;
using System.Collections;
using System.Collections.Generic;
using uoLib;

namespace uoLib.example
{
    static class showFunctions
    {
        public static void Start()
        {

            //------------------------------------------------
            Console.WriteLine("演示GetRadomNum()");
            for (int i = 5; i <= 9; i++)
            {
                Console.WriteLine("\t{0} 位随机数: {1}", i, Functions.GetRandomNum(i));
            }
            Console.WriteLine();

            //------------------------------------------------
            Console.WriteLine("演示FormatFileSize()");
            List<long> list1 = new List<long>();
            list1.Add(1073741824);
            list1.Add(1048576);
            list1.Add(1024);
            list1.Add(154);
            list1.Add(5464665464);
            list1.Add(5456564665464);
            IEnumerator ie = list1.GetEnumerator();
            while (ie.MoveNext())
            {
                Console.WriteLine("\t{0}: {1}", ie.Current, Functions.FormatFileSize((long)ie.Current));
            }
            Console.WriteLine();

            //------------------------------------------------
            Console.WriteLine("演示IsNullOrEmptyStr()");
            Console.WriteLine("\tIsNullOrEmptyStr(String.Empty): {0}", Functions.IsNullOrEmptyStr(String.Empty));
            Console.WriteLine("\tIsNullOrEmptyStr(null): {0}", Functions.IsNullOrEmptyStr(null));
            Console.WriteLine("\tIsNullOrEmptyStr(' '): {0}", Functions.IsNullOrEmptyStr(" "));
            Console.WriteLine("\tIsNullOrEmptyStr('sdf'): {0}", Functions.IsNullOrEmptyStr("sdf"));
            Console.WriteLine("\tIsNullOrEmptyStr(1): {0}", Functions.IsNullOrEmptyStr(1.ToString()));
            Console.WriteLine();

            //------------------------------------------------
            Console.WriteLine("演示HtmlToJs()");
            Console.WriteLine("\tHtmlToJs(String.Empty): {0}", Functions.HtmlToJs(String.Empty));
            Console.WriteLine("\tHtmlToJs(\" \" \"): {0}", Functions.HtmlToJs(Char.ConvertFromUtf32(34)));
            Console.WriteLine();

            //------------------------------------------------
            Console.WriteLine("演示IsValidName()");
            Console.WriteLine("\tIsValidName(String.Empty): {0}", Functions.IsValidName(String.Empty));
            Console.WriteLine("\tIsValidName(null): {0}", Functions.IsValidName(null));
            Console.WriteLine("\tIsValidName(\"dffd.gfg\"): {0}", Functions.IsValidName("dffd.gfg"));
            Console.WriteLine("\tIsValidName(\"dffd*gfg\"): {0}", Functions.IsValidName("dffd*gfg"));
            Console.WriteLine("\tIsValidName(\"dffd gfg\"): {0}", Functions.IsValidName("dffd gfg"));
            Console.WriteLine();

            //------------------------------------------------
            Console.WriteLine("演示IsValidEmail()");
            Console.WriteLine("\tIsValidEmail(String.Empty): {0}", Functions.IsEmail(String.Empty));
            Console.WriteLine("\tIsValidEmail(null): {0}", Functions.IsEmail(null));
            Console.WriteLine("\tIsValidEmail(\"sdfsdklgf\"): {0}", Functions.IsEmail("sdfsdklgf"));
            Console.WriteLine("\tIsValidEmail(\"sdfsd@klgf\"): {0}", Functions.IsEmail("sdfsd@klgf"));
            Console.WriteLine("\tIsValidEmail(\"sdfsd@.com\"): {0}", Functions.IsEmail("sdfsd@.com"));
            Console.WriteLine("\tIsValidEmail(\"sdfsd@aa.com.\"): {0}", Functions.IsEmail("sdfsd@aa.com."));
            Console.WriteLine("\tIsValidEmail(\"sdADsgGsd@klRf.com\"): {0}", Functions.IsEmail("sdADsgGsd@klRf.com"));

            Console.WriteLine();

            //------------------------------------------------
            Console.WriteLine("演示CutStr()");
            Console.WriteLine("\tCutStr(\"<span>dfgdgs5d4fagd</span>gdfg\",5): {0}", Functions.CutStr("<span>dfgdgs5d4fagd</span>gdfg", 5));
            Console.WriteLine("\tCutStr(\"<span>dfgdgs5d4fagd</span>gdfg\",8,true): {0}", Functions.CutStr("<span>dfgdgs5d4fagd</span>gdfg", 8, true));
            Console.WriteLine("\tCutStr(\"中文按几个字符算的呢？\",5): {0}", Functions.CutStr("中文按几个字符算的呢？", 5));
            Console.WriteLine("\tCutStr(\"中文\",5): {0}", Functions.CutStr("中文", 5));
            Console.WriteLine("\tCutStr(\"五个中文字\",5): {0}", Functions.CutStr("五个中文字", 5));


            Console.WriteLine();
        }
    }
}
